/**************************************************************************************************
* Title: SumMain.cpp
* Author: Gael Huber
* Description: Main class of the engine. Responsible for launching the engine proper.
**************************************************************************************************/
#include <Windows.h>
#include "SumSimulationManager.h"

// Test environment for deep subsystems
#include <SumDataTypes.h>
#include "SumTimer.h"
#include "SumArray.h"
#include "SumOrderedArray.h"
#include "SumHashMap.h"
#include <D3DX10math.h>
#include <vector>
#include <string>
#include <xnamath.h>
#include <unordered_map>
#include <list>
#include <hash_map>
#include "SumList.h"
//#include <unordered_map>
using namespace std;


void test(void) {
	seed();

	String bob = "Hello";
	string bob2 = "hello";
	const char* b2 = bob2.c_str();
	unordered_map<string, int> a1;
	unordered_map<String, int> a2;
	a1[bob2] = 2;
	a2[bob] = 1;

	int numTrials = 100;
	int numReps = 10000;
	float time = 0.0f;
	Timer t = Timer();
	t.start();
	for(int j = 0; j < numTrials; j++) {
		HashMap<String, int> a;
		String str = "a";
		for(int i = 0; i < numReps; i++) {
			a[str] = i;
			str += "a";
		}
		time += t.deltaTime_f_no_max();
	}
	float avgTime(time / numTrials);
	
	float time2 = 0.0f;
	Timer t2 = Timer();
	t2.start();
	for(int j = 0; j < numTrials; j++) {
		unordered_map<string, int> a;
		string s = "a";
		for(int i = 0; i < numReps; i++) {
			a[s] = i;
			s += "a";
		}
		time2 += t2.deltaTime_f_no_max();
	}
	float avgTime2(time2 / numTrials);

	int aa = 0;
};

/**************************************************************************************************
* Main method of the engine.
**************************************************************************************************/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
	//test();
	
	// Set hInstance
	SetHInstance(hInstance);

	// Initialize the simulation
	SimulationManager* simulation = new SimulationManager();

	// Startup the simulation
	simulation->startUp(nCmdShow);
	
	// Run the simulation
	simulation->run();

	// Shutdown the simulation
	simulation->shutDown();

	// Return 0 to Windows at the end of the program
	return 0;
}